package com.mind.battle;

import java.util.HashMap;
import java.util.Map;

import com.mind.login.model.Player;

public class Room {
	private short roomId;
	public Room(short roomId){
		this.roomId=roomId;
	}
	
	public short getRoomId() {
		return roomId;
	}

	private Map<String, Player> players=new HashMap<String, Player>();
	public boolean contains(String playerId){
		return players.containsKey(playerId);
	}
	public void enterRoom(Player player){
		players.put(player.id(), player);
		for(Player player2:players.values()){
			if(!player.id().equals(player2.id())){
				EnterBattleRoomMessage msg=new EnterBattleRoomMessage(
						this.roomId,
						player.battleProperty.getX(), player.battleProperty.getY(), player.battleProperty.getxSpeed(),
						player.battleProperty.getySpeed(), player.battleProperty.getxDriction(), player.battleProperty.getyDriction());
				player2.sendMessage(msg);		
			}
		}
		
		
	}
	
}
